/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nus.dataaccess.dao.event;

import com.nus.dataaccess.dao.base.BaseEntity;
import com.nus.dataaccess.dao.conference.Conference;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;









import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

import javax.persistence.TemporalType;

/**
 *
 * @author
 */

@SuppressWarnings("serial")
@DynamicUpdate
@DynamicInsert
@Entity
@Table(name="EVENT")
public class Event extends BaseEntity{

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    public Long getId() {return id;}
    public void setId(Long id) {this.id = id;}
    @Override
    public Serializable getPk() {return this.getId();}

    @Column(name="NAME")
    private String name;
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}

    @Column(name="DETAIL")
    private String detail;
    public String getDetail() {return detail;}
    public void setDetail(String detail) {this.detail = detail;}

    @Column(name="LOCATION")
    private String location;
    public String getLocation() {return location;}
    public void setLocation(String location) {this.location = location;}

    @Column(name="STARTDATE")
    private String startDate;
    public String getStartDate() {return startDate;}
    public void setStartDate(String startTime) {this.startDate = startDate;}

    @Column(name="ENDDATE")
    private String endDate;
    public String getEndDate() {return endDate;}
    public void setEndDate(String endtime) {this.endDate = endDate;}

    @Column(name="TOPIC")
    private String topic;
    public String getTopic() {return topic;}
    public void setTopic(String topic) {this.topic = topic;}

    @Column(name="DATETIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datetime;
    public Date getDatetime() {return datetime;}
    public void setDatetime(Date datetime) {this.datetime = datetime;}

    @Column(name="PRICE")
    private Double price = new Double(0.00);
    public Double getPrice() {return price;}
    public void setPrice(Double price) {this.price = price;}

    @Column(name="CONFERENCE_ID")
    private Long conferenceId;
    public Long getConferenceId() {return conferenceId;}
    public void setConferenceId(Long conferenceId) {this.conferenceId = conferenceId;}

    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="CONFERENCE_ID", referencedColumnName="ID",insertable=false,updatable=false)
    private Conference conference;
    public Conference getConference() {return conference;}
    public void setConference(Conference conference) {
        this.conference = conference;
        this.setConferenceId((conference!= null ) ? conference.getId() : null);
    }

}
